package com.sky.mapper.admin;

import com.github.pagehelper.Page;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

/*
* @Insert("insert into category(type, name, sort, status, create_time, update_time, create_user, update_user)" +
            " VALUES" +
            " (#{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")*/
@Mapper
public interface CategoryMapper {
    //@Select("select * from category where type = #{type} order by sort asc,create_time desc")
    List<Category> findCategoryByType(Integer type);

    Page<Category> pageByCategory(CategoryPageQueryDTO categoryPageQueryDTO);

    @Insert("insert into category(type, name, sort, status, create_time, update_time, create_user, update_user) values (#{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    int addCategory(Category category);

    @Delete("delete from category where id= #{id}")
    int deleteCategoryById(@Param("id") Integer id);

    int updateCategory(Category category);

    @Update("update category set status = #{status} where id = #{id}")
    int updateStatus(@Param("status") Integer status, @Param("id") Long id);


}
